/**
 * 
 */
package com.rapwaves.feeds.content.widgets;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Widget;
import com.rapwaves.feeds.content.beans.PhotoContent;

/**
 * @author asanthan
 * 
 */
public class PhotoContentUI extends Composite {

	private static PhotoContentUiBinder uiBinder = GWT.create(PhotoContentUiBinder.class);

	interface PhotoContentUiBinder extends UiBinder<Widget, PhotoContentUI> {
	}

	public PhotoContentUI(PhotoContent bean) {
		initWidget(uiBinder.createAndBindUi(this));
		photoLink = bean.getLink();
		photo.setUrl(bean.getPhotoUrl());
	}

	private String photoLink;
	
	@UiField
	Image photo;

	public String getPhotoLink() {
		return photoLink;
	}

	public void setPhotoLink(String photoLink) {
		this.photoLink = photoLink;
	}
	
	@UiHandler(value="photo")
	void onClick(ClickEvent e) {
		Window.open(photoLink, "_blank", "");
	}

	public Image getPhoto() {
		return photo;
	}

	public void setPhoto(Image photo) {
		this.photo = photo;
	}
	
	
}
